package cn.cdiothree.converter;

import cn.cdiothree.DTO.OrderDTO;
import cn.cdiothree.dataobject.ProductOrder;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 将ProductOrder中的信息传入到OrderDTO中
 */
public class ProductOrder2OrderDTOConverter {
    public static OrderDTO convert(ProductOrder productOrder){

        OrderDTO orderDTO=new OrderDTO();

        BeanUtils.copyProperties(productOrder,orderDTO);
        return orderDTO;
    }

    public static List<OrderDTO> convert(List<ProductOrder> productOrderList){
        return productOrderList.stream().map(e ->
                convert(e)
                ).collect(Collectors.toList());
    }
}
